﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XiTongUser.aspx.cs" Inherits="PropertyAppraisal.SystemManage.XiTongUser" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>

    <link rel="stylesheet" type="text/css" href="../easyui/easyui/1.3.2/themes/default/easyui.css" />
    <link href="../easyui/easyui/1.3.2/themes/icon.css" rel="stylesheet" />
    <script src="../easyui/easyui/1.3.2/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../easyui/easyui/1.3.2/jquery.easyui.min.js"></script>
    <script src="../easyui/easyui/1.3.2/locale/easyui-lang-zh_CN.js"></script>
    <script src="../easyui/easyui/1.3.2/easyloader.js"></script>
           <%--转换时间格式--%>
     <script src="../Tools/TimeJs.js"></script>
</head>
<body>
    <div fit="true">
            <iframe width="0" height="0" src="../SessionKeeper.aspx"></iframe>   
        <div style="padding: 3px">
            <a href="javascript:void(0) " class="easyui-linkbutton" data-options="iconCls:'icon-add',toggle:true" onclick="addemp()">添加员工</a>
            <input class="easyui-textbox" id="name" type="text" name="empname" data-options="required:true" placeholder="请输入员工名称查询" maxlength="20" />
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',toggle:true" id="search" >查询</a>
        </div>
        <table id="ta" title="员工列表" style="width: 1190px; height: 600px" data-options="
				rownumbers:true,
				singleSelect:true,
				autoRowHeight:false,
				pagination:true,
				pageSize:10">
            <thead>
                <tr>
                    <th field="userId" width="120" align="center">ID</th>
                    <th field="userName" width="150" align="center">员工姓名</th>
                    <th field="IdName" width="120" align="center">员工账号</th>
                    <th field="linkNum" width="120" align="center">联系电话</th>
                    <th field="addTime" width="120" align="center">加入时间</th>
                    <th field="isUse" width="150" align="center">是否启用</th>
                    <th field="cao" width="270" align="center">操作</th>
                </tr>
            </thead>
        </table>
    </div>
    <script type="text/javascript">

        //停用
        function users_IsState(users_IsState, users_Name) {
            $.ajax({
                type: "post", //要用post方式                 
                url: "XiTongUser.aspx/updateState",//方法所在页面和方法名
                data: "{'users_IsState':'" + users_IsState + "','users_Name':'" + users_Name + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function (result) {
                    var json = eval("(" + result.d + ")");
                    alert(json);
                }
            });
        }

        //跳转到新增员工
        function addemp() {
            parent.addTab("新增员工信息", "/SystemManage/XiTongAddEmp.aspx", "", true);
        }

        //表格
        function getData(obj) {
            var rows = [];
            $.ajax({
                type: "post", //要用post方式                 
                url: "XiTongUser.aspx/showUsers",//方法所在页面和方法名
                contentType: "application/json; charset=utf-8",
                data:"{ 'name': '" + obj + "' }",
                dataType: "json",
                async: false,
                success: function (result) {
                    var json = eval("(" + result.d + ")");

                    for (var i = 0; i < json.length; i++) {
                        rows.push({
                            userId: json[i].users_Id,
                            userName: json[i].users_Name,
                            IdName: json[i].users_Account,
                            linkNum: json[i].users_TEL,
                            addTime: (new Date(json[i].users_CreateTime)).Format("yyyy-M-d h:m:s.S"),
                            isUse: json[i].users_IsState == 0 ? "启用" : "未启用",
                            cao: '<input type="button" value="删除" class="easyui-linkbutton"/><input type="button" value="修改" class="easyui-linkbutton"/>' +
                                     '<input type="button" class="easyui-linkbutton" value="停用" onclock="users_IsState(\'' + json[i].users_IsState + '\'+\'' + json[i].users_Name + '\')"/>' + '<input class="easyui-linkbutton" type=\"button\" value=\"启用\" />',
                        });
                    }
                }
            })
            return rows;
        }
        $("#search").bind('click', function () {
            data();
        })
        function pagerFilter(data) {
            if (typeof data.length == 'number' && typeof data.splice == 'function') {	// is array
                data = {
                    total: data.length,
                    rows: data
                }
            }
            var dg = $(this);
            var opts = dg.datagrid('options');
            var pager = dg.datagrid('getPager');
            pager.pagination({
                onSelectPage: function (pageNum, pageSize) {
                    opts.pageNumber = pageNum;
                    opts.pageSize = pageSize;
                    pager.pagination('refresh', {
                        pageNumber: pageNum,
                        pageSize: pageSize
                    });
                    dg.datagrid('loadData', data);
                },
                onRefresh: function (pageNum, pageSize) {
                    var name = $("#name").val();
                    $('#ta').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', getData(name));
                }
            });
            if (!data.originalRows) {
                data.originalRows = (data.rows);
            }
            var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
            var end = start + parseInt(opts.pageSize);
            data.rows = (data.originalRows.slice(start, end));
            return data;
        }

        $(function () {
            data();
        });
        function data() {
            var name = $("#name").val();
            $('#ta').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', getData(name));
        }
    </script>
</body>
</html>


